﻿using System;

namespace Shapes
{
    class Triangle : IShape
    {
        public double Side1 { get; set; }
        public double Side2 { get; set; }
        public double Side3 { get; set; }

        public Triangle(double side1, double side2, double side3)
        {
            Side1 = side1;
            Side2 = side2;
            Side3 = side3;
        }

        public double CalculateArea()
        {
            // 使用海伦公式计算三角形面积
            double s = (Side1 + Side2 + Side3) / 2;
            return Math.Sqrt(s * (s - Side1) * (s - Side2) * (s - Side3));
        }

        public bool IsShapeValid()
        {
            return Side1 > 0 && Side2 > 0 && Side3 > 0 &&
                   Side1 + Side2 > Side3 &&
                   Side1 + Side3 > Side2 &&
                   Side2 + Side3 > Side1;
        }
    }
}